package test.com.geeksaga.util;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * @author newbie
 * @since 0.1
 */
public class BundleUtils {

	/**
	 * @param bundleName 
	 * @param key 
	 */
	public static String getString(String bundleName, String key) {

		Locale locale = Locale.KOREA;
		ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);

		String text = null;

		try {
			text = bundle.getString(key);
		} catch (MissingResourceException e) {
			text = "[warning] resource Bundle key  : [" + key + "] not found...";
		}
		return text;
	}
	
	/**
	 * @param bundleName 
	 * @param key 
	 * @param locale
	 */
	public static String getString(String bundleName, String key, Locale locale) {

		ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);
		String text = null;

		try {
			text = bundle.getString(key);
		} catch (MissingResourceException e) {
			text = "[warning] resource Bundle key  : [" + key + "] not found...";
		}
		return text;
	}
}